<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
         *{
            padding: 0;
            margin: 0;
            list-style: none;
            box-sizing: border-box;
        }
        .on{
            color:red;
        }
        .title{
            width: 300px;
            height: 40px;
            display: flex;
            align-items: center;
            justify-content: space-around;
        }

    </style>
</head>
<body>
    <div id="app">
        <ul class="title">
            <li
            v-for="(item,index) in list"
            @click="changeIndex(index)"
            v-bind:class="{on:activeIndex==index}"
            >
                {{item.title}}{{index}}
            </li>
        </ul>
        <div class="body">
            <p v-for="item in list[activeIndex].children">
                {{item}}
            </p>
        </div>
    </div>
    <script src="./vue.js"></script>
    <script>
        const vue=new Vue({
            el:'#app',
            data(){
                return{
                    list: [{
                    title: '一组',
                    children: ['郭班长', '李飞帆', '张晓腾']
                }, {
                    title: '二组',
                    children: ['大生委', '张畅', '张力宁']
                }, {
                    title: '三组',
                    children: ['张国运', '司淼淼', '邵婉仪']
                },],
                activeIndex:0
                }
            },
            methods: {
                changeIndex(index) {
                    console.log(index);
                    this.activeIndex=index
                },
            },
        })
    </script>
</body>
</html>